<!--
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-07-31 17:46:49
 * @LastEditTime: 2020-03-14 14:35:14
 * @LastEditors: Please set LastEditors
 -->
<!doctype html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport"
		content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
	<title>Hello APP</title>
	<link rel="stylesheet" type="text/css" href="../../css/vant.css">
	<link rel="stylesheet" type="text/css" href="../../css/base.css" />
	<script type="text/javascript" src="../../script/jquery.js"></script>
	<script type="text/javascript" src="../../script/layer/mobile/layer.js"></script>
	<script type="text/javascript" src="../../script/vue.min.js"></script>
	<script type="text/javascript" src="../../script/vant.min.js"></script>
	<script type="text/javascript" src="../../script/fastclick.js"></script>
	<script type="text/javascript" src="../../script/base.js"></script>
	<style type="text/css">
		.content {
			background: #fff !important;
		}

		.h-h {
			background: #f8f9fb;
			color: #949faa;
			font-size: 14px;
		}

		.h-h .h-label {
			vertical-align: middle;
		}

		.h-h .sort {
			margin-left: 2px;
			width: 15px;
			vertical-align: middle;
		}

		.h-h .sort-tran {
			transform: rotate(180deg);
		}

		.h-p {
			position: relative;
		}

		.h-t {
			height: calc(100% - 45px);
			overflow: auto;
			-webkit-overflow-scrolling: touch;
		}

		.h-t .h-p:nth-child(even) {
			background: #fafcfb;
		}

		.h-r {
			position: relative;
		}

		.h-p .h-l {
			position: absolute;
			left: 0;
			top: 0;
			width: 40px;
			height: 44px;
			line-height: 44px;
			text-align: center;
			color: #969799;
			z-index: 1;
			padding-top: 2px;
		}

		.h-p .h-r {
			padding-left: 40px;
		}

		.h-r .h-c {
			overflow: hidden;
		}

		.h-r .h-c>div {
			float: left;
			height: 44px;
			line-height: 44px;
			text-align: left;
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;
			padding-left: 10px;
			font-size: 13px;
		}

		.h-r .h-s .van-cell {
			background-color: transparent;
			color: #969799;
			padding: 2px 6px;
		}

		.h-r .h-s .van-cell .van-cell__title {
			font-weight: 500;
		}

		.h-r .h-s .van-cell:not(:last-child)::after {
			display: none;
		}

		.h-r .h-s .van-cell .van-cell__value {
			color: #969799;
		}

		.tab-row {
			height: 100%;
		}

		.bottom-left-label span {
			margin-left: 10px;
		}
	</style>
</head>

<body>
	<div id="app" v-cloak>
		<div class="init-full">
			<van-nav-bar class="head" :title="titleName" left-arrow @click-left="onClickLeft">
				<div slot="right" class="head-right">
					<span @click="showSearch = true;">
						<img src="../../image/search.png" />
					</span>
				</div>
			</van-nav-bar>
			<div class="body-with-bottom">
				<div class="content">

					<div class="tab-row" v-if="!isShowStatus()">
						<div class="h-h">
							<div class="h-p">
								<div class="h-l"></div>
								<div class="h-r">
									<div class="h-c">
										<div v-for="(col,index2) in columns" v-show="!col.isHidden && !col.isFold"
											:style="{width:col.colWidth + '%'}">
											<div @click="sortSearch(col)">
												<span class="h-label">{{col.colDesc}}</span>
												<img class="sort" v-show="col.isOrder"
													:class="col.querySort == 'asc'?'':'sort-tran'"
													src="../../image/sort.png">
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>

						<div class="h-t">
							<van-list v-model="listLoading" :finished="listFinished" finished-text="没有更多了"
								@load="listOnLoad">
								<div class="h-p" v-for="(row,index1) in resultArray" @click="intoPage(row)">
									<div class="h-l" @click.stop="toggleFold(row)">
										<van-icon name="arrow-down"></van-icon>
									</div>
									<div class="h-r">
										<div class="h-c">
											<div v-for="(col,index2) in columns" v-show="!col.isHidden && !col.isFold"
												:style="{width:col.colWidth + '%'}">{{getRowName(row,col)}}
											</div>
										</div>
										<div class="h-s" v-show="!row.noFold">
											<van-cell v-for="(col,index2) in columns" v-show="col.isFold"
												:title="col.colDesc" :value="getRowName(row,col)"></van-cell>
										</div>
									</div>
								</div>

							</van-list>
						</div>
					</div>



					<van-tabs v-model="tabActive" @change="changeTab" v-if="isShowStatus()">
						<van-tab title="未过账">
							<div class="tab-row">
								<div class="h-h">
									<div class="h-p">
										<div class="h-l"></div>
										<div class="h-r">
											<div class="h-c">
												<div v-for="(col,index2) in columns"
													v-show="!col.isHidden && !col.isFold"
													:style="{width:col.colWidth + '%'}">
													<div @click="sortSearch(col)">
														<span class="h-label">{{col.colDesc}}</span>
														<img class="sort" v-show="col.isOrder"
															:class="col.querySort == 'asc'?'':'sort-tran'"
															src="../../image/sort.png">
													</div>
												</div>
											</div>
										</div>
									</div>
								</div>

								<div class="h-t">
									<van-list v-model="listLoading" :finished="listFinished" finished-text="没有更多了"
										@load="listOnLoad">
										<div class="h-p" v-for="(row,index1) in resultArray" @click="intoPage(row)">
											<div class="h-l" @click.stop="toggleFold(row)">
												<van-icon name="arrow-down"></van-icon>
											</div>
											<div class="h-r">
												<div class="h-c">
													<div v-for="(col,index2) in columns"
														v-show="!col.isHidden && !col.isFold"
														:style="{width:col.colWidth + '%'}">{{getRowName(row,col)}}
													</div>
												</div>
												<div class="h-s" v-show="!row.noFold">
													<van-cell v-for="(col,index2) in columns" v-show="col.isFold"
														:title="col.colDesc" :value="getRowName(row,col)"></van-cell>
												</div>
											</div>
										</div>

									</van-list>
								</div>
							</div>
						</van-tab>
						<van-tab title="已过账">
							<div class="tab-row">
								<div class="h-h">
									<div class="h-p">
										<div class="h-l"></div>
										<div class="h-r">
											<div class="h-c">
												<div v-for="(col,index2) in columns"
													v-show="!col.isHidden && !col.isFold"
													:style="{width:col.colWidth + '%'}">
													<div @click="sortSearch(col)">
														<span class="h-label">{{col.colDesc}}</span>
														<img class="sort" v-show="col.isOrder"
															:class="col.querySort == 'asc'?'':'sort-tran'"
															src="../../image/sort.png">
													</div>
												</div>
											</div>
										</div>
									</div>
								</div>

								<div class="h-t">
									<van-list v-model="listLoading" :finished="listFinished" finished-text="没有更多了"
										@load="listOnLoad">
										<div class="h-p" v-for="(row,index1) in resultArray" @click="intoPage(row)">
											<div class="h-l" @click.stop="toggleFold(row)">
												<van-icon name="arrow-down"></van-icon>
											</div>
											<div class="h-r">
												<div class="h-c">
													<div v-for="(col,index2) in columns"
														v-show="!col.isHidden && !col.isFold"
														:style="{width:col.colWidth + '%'}">{{getRowName(row,col)}}
													</div>
												</div>
												<div class="h-s" v-show="!row.noFold">
													<van-cell v-for="(col,index2) in columns" v-show="col.isFold"
														:title="col.colDesc" :value="getRowName(row,col)"></van-cell>
												</div>
											</div>
										</div>

									</van-list>
								</div>
							</div>
						</van-tab>
					</van-tabs>



				</div>
				<van-loading v-if="showLoading" />
			</div>
			<div class="bottom">
				<div class="bottom-left-label" style="padding: 0 10px 0 10px;">
					<span style="color: #969799;">共计{{paging.totalCount}}条数据</span>
					<span v-for="row in summaryData">合计{{row.desc}}：<b style="color: #cd1b21;">{{row.value}}</b></span>
				</div>
			</div>

			<van-popup v-model="showSimpleSelect" position="bottom">
				<van-picker show-toolbar v-if="pickerIndex > -1 && columns[pickerIndex].selDetail"
					:columns="simpleColumns" :value-key="columns[pickerIndex].selDetail.displayValue"
					@cancel="showSimpleSelect = false" @confirm="simpleSelectChange"></van-picker>
			</van-popup>

			<van-popup v-model="showDatePicker" position="bottom">
				<van-datetime-picker v-model="currentDate" cancel-button-text="清空" type="date" @cancel="clearDatePicker"
					@confirm="confirmDatePicker" />
			</van-popup>


			<van-popup v-model="showSearch" round position="bottom">
				<div v-for="(row,index) in columns" v-show="row.isColQuery">
					<van-cell v-if="row.colDataType == 'datetime'" :title="row.colDesc" :value="row.queryKey"
						@click="openDatePicker(index)">
					</van-cell>
					<van-cell v-else-if="row.colDataType == 'bit'" :title="row.colDesc">
						<div style="text-align:right;">
							<van-switch v-model="row.queryKey" size="22px"></van-switch>
						</div>
					</van-cell>
					<div v-else-if="row.colType==2">
						<van-cell v-if="row.selDetail.type==1" :title="row.colDesc"
							:value="showSelectTableDisplayValue(row.selDetail,row.queryKey)" is-link
							arrow-direction="down" @click="openSimpleSelect(index,row)">
						</van-cell>
						<van-cell v-if="row.selDetail.type==3" :title="row.colDesc"
							:value="showSelectTableDisplayValueByAjax(row.selDetail,row.queryKey)" is-link
							@click="openComplexSelect(index,row)">
						</van-cell>
					</div>
					<van-cell v-else-if="row.colType==4" :title="row.colDesc">
						<div>
							<van-stepper v-model="row.queryKey"></van-stepper>
						</div>
					</van-cell>
					<van-field v-else :label="row.colDesc" v-model="row.queryKey">
					</van-field>
				</div>
				<div class="btn-padding">
					<van-button type="primary" block style="border-radius: 0;" @click="searchList">查询</van-button>
				</div>
			</van-popup>
		</div>
	</div>
</body>

<script type="text/javascript">
	var vm;
	apiready = function () {
		//$('.init-full').show();

		var billRole = JSON.parse(window.localStorage.getItem('billRole'))


		function getBillRoleList(data) {
			let filterSQL = "";
			let moduleName = data.replace(/app_/g, '');
			let billList = billRole.filter(item => item.FListName == moduleName);
			if (billList.length > 0) {
				if (billList[0]["T_Value"] != '-1') {
					filterSQL += '(';
					//权限业务逻辑
					let colTypes = [];//已执行过的类型列
					let colSQLType = [];//多类型SQL集合
					billList.forEach(item => {
						if (item["SC_ColA"]) {
							if (colTypes.filter(x => x == item["SC_ColA"]).length == 0) {
								let sc_colAs = [];
								let sc_colBs = [];
								let current_filterSQL = "";
								let current_billType = billList.filter(x => x["SC_ColA"] == item["SC_ColA"]);
								for (var i = 0; i < current_billType.length; i++) {
									sc_colAs.push("'" + current_billType[i]["T_Value"] + "'");
									if (current_billType[i]["SC_ColB"]) {
										sc_colBs.push("'" + current_billType[i]["T_Value"] + "'");
									}
								}
								if (sc_colAs.length > 0) {
									current_filterSQL += ' ' + item["SC_ColA"] + " in (" + sc_colAs.join(",") + ")"
									if (sc_colBs.length > 0) {
										current_filterSQL += " or " + current_billType[0]["SC_ColB"] + " in (" + sc_colBs.join(",") + ") "
									}
								}
								if (current_filterSQL) {
									current_filterSQL = " (" + current_filterSQL + ") ";
									colSQLType.push(current_filterSQL);
								}
								colTypes.push(item["SC_ColA"]);
							}
						}
					})
					filterSQL += colSQLType.join(" and ");
					filterSQL += " ) "
				}
			}
			return filterSQL;
		}

		//复杂下拉选单选选中
		api.addEventListener({
			name: 'selectHistoryRow'
		}, function (ret, err) {
			var row = ret.value.row;
			vm.columns[vm.pickerIndex].queryKey = row[vm.columns[vm.pickerIndex].selDetail.hiddenValue];
			vm.$set(vm.columns[vm.pickerIndex].selDetail, "sqlDataSource", [row]);
		})

		//复杂下拉选单选选中
		api.addEventListener({
			name: 'selectHistoryArray'
		}, function (ret, err) {
			var array = ret.value.array;
			var col = vm.columns[vm.pickerIndex[1]];
			var idArray = [];
			for (var i in array) {
				idArray.push(array[i][vm.columns[vm.pickerIndex].selDetail.hiddenValue])
			}
			vm.columns[vm.pickerIndex].queryKey = idArray.join();
			vm.$set(vm.columns[vm.pickerIndex].selDetail, "sqlDataSource", array);
		})


		vm = new Vue({
			el: '#app',
			data: {
				showLoading: false,
				listLoading: false,
				listFinished: true,
				showSearch: false,
				showDatePicker: false,
				showSimpleSelect: false,
				simpleColumns: [],
				currentDate: new Date(),
				pickerIndex: -1,
				searchKey: "",
				tabActive: 0,

				titleName: api.pageParam.titleName || "",
				objName: api.pageParam.objName,

				currentCol: "",
				paging: {
					pageSize: 30,
					pageIndex: 1,
					totalCount: 0
				},
				mainKey: "",
				columns: [],
				params: [],
				// searchFilterArray: [],
				resultArray: [],
				selectArray: [],
				filterStr: "",
				filterDefault: "isnull(Status,0)<80",
				summaryData: []
			},
			created: function () {
				this.getColumns();
			},
			methods: {
				changeTab() {
					var that = this;
					if (that.tabActive == 0) {
						that.filterDefault = 'isnull(Status,0)<80'
					} else {
						that.filterDefault = 'Status >= 80'
					}
					that.paging.pageIndex = 1;
					$('.tab-row').scrollTop(0);
					that.searchList();
				},
				getRowName(row, col) {
					var that = this;
					if (col.colDataType == 'date') {
						return (row[col.colName] || '').split('T')[0];
					} else if (col.colDataType == 'datetime') {
						return (row[col.colName] || '').replace(/T/g, ' ').split('.')[0];
					} else if (col.colDataType == 'time') {
						return (row[col.colName] || '').split('T')[1].split('.')[0];
					} else {
						if (col.colType == 2) {
							if (col.selDetail.type == 1) {
								return that.showSelectTableDisplayValue(col.selDetail, row[col.colName])
							} else if (col.selDetail.type == 3) {
								return that.showSelectTableDisplayValueByAjax(col.selDetail, row[col.colName])
							} else {
								return row[col.colName];
							}
						} else {
							return row[col.colName];
						}

					}
				},
				isShowStatus() {
					var that = this;
					if (that.columns) {
						var s = false;
						for (var i in that.columns) {
							if (that.columns[i].colName == "Status") {
								s = true;
							}
						}
						return s;
					}else{
						return false;
					}
				},
				getColumns() {
					var that = this;
					FLD.formConfigAjax('AppFormList/GetDataByName', {
						programId: localStorage.getItem("programId"),
						objName: that.objName
					}, function (data) {
						var filterCondition = data.ds[0]["filterCondition"] || '';
						var userInfo = FLD.getUserInfo();
						if(that.objName == 'app_开票申请主表'){
							userInfo.S_ClientID = 0;
						}
						for (var key in userInfo) {
							var value = "'" + userInfo[key] + "'";
							filterCondition = eval("filterCondition.replace(/" + "@" + key + "/g,value)")
						}
						if (!filterCondition) {
							filterCondition += getBillRoleList(data.ds[0]['name'])
						} else {
							filterCondition += " and " + (getBillRoleList(data.ds[0]['name']) || " 1=1 ") + " ";
						}
						vm.columns = JSON.parse(data.ds[0]["columnsConfig"]);

						for (var i in vm.columns) {
							if (vm.columns[i].isOrder) {
								vm.columns[i].defaultQuerySort = vm.columns[i].querySort
							}

							// if (vm.columns[i].isSearchCol) {
							// 	vm.searchFilterArray.push(JSON.parse(JSON.stringify(vm.columns[i])))
							// }
							if (vm.columns[i].isKey) {
								vm.mainKey = vm.columns[i].colName;
							}
						};
						vm.params = {
							isFormList: data.ds[0]["isFormList"],
							physicalTableName: data.ds[0]["physicalTableName"],
							isPaging: data.ds[0]["isPaging"],
							detailName: data.ds[0]["detailName"],
							filterCondition: filterCondition,
							defaultOrder: data.ds[0]["defaultOrder"]
						}
						if (filterCondition) {
							vm.filterStr = filterCondition + " and " + vm.filterDefault;
						} else {
							vm.filterStr = vm.filterDefault;
						}
						vm.calSummaryData();
						vm.refreshFilterCol();

						vm.setLists();
					})

				},
				calSummaryData() {
					var listSummaryColumns = [];
					var summaryData = [];
					for (var i = 0; i < vm.columns.length; i++) {
						if (vm.columns[i].colTotalFunction && !vm.columns[i].isHidden) {
							listSummaryColumns.push(vm.columns[i].colTotalFunction + "(" + vm.columns[i].colName + ") as " + vm.columns[i].colName + "");
							summaryData.push({
								desc: vm.columns[i].colDesc,
								name: vm.columns[i].colName,
								value: 0
							});
						}
					}
					$.post("http://" + FLD.serverIP + "/SQLData/GetSummaryData", {
						programId: localStorage.getItem("programId"),
						tableName: vm.params.physicalTableName,
						filterCondition: vm.filterStr,
						listSummaryColumns: listSummaryColumns
					}, function (data) {
						if (data.status == 200) {
							if (data.data.ds.length > 0) {

								for (var i in summaryData) {
									summaryData[i].value = data.data.ds[0][summaryData[i].name]
								}

								vm.summaryData = summaryData;

							}
						}
					}, "json");
				},
				refreshFilterCol() {
					var that = this;
					for (var i = 0; i < that.columns.length; i++) {
						//下拉框数据加载
						if (that.columns[i].colType == 2 && that.columns[i].selDetail.type < 3) {
							var sql = that.columns[i].selDetail.dataSource;
							$.ajax({
								url: "http://" + FLD.serverIP + "/SQLData/GetDataBySql",
								async: false,
								data: {
									programId: localStorage.getItem("programId"),
									sql: sql
								},
								type: "post",
								dataType: 'json',
								success: function (data) {
									if (data.status == 200) {
										that.$set(that.columns[i].selDetail, "sqlDataSource", data.data.ds);
										that.$set(that.columns[i], 'filters', data.data.ds);
									}
								}
							});
						} else if (that.columns[i].colType == 2 && that.columns[i].selDetail.type == 3) {
							var valueList = [];
							var sql = "select * from (" + that.columns[i].selDetail.dataSource + ")t";
							if (valueList.length > 0) {
								sql += " where " + that.columns[i].selDetail.hiddenValue + " in (" + valueList.join(',') + ") ";
								$.ajax({
									url: "http://" + FLD.serverIP + "/SQLData/GetDataBySql",
									async: false,
									data: {
										programId: localStorage.getItem("programId"),
										sql: sql
									},
									type: "post",
									dataType: 'json',
									success: function (data) {
										if (data.status == 200) {
											that.$set(that.columns[i].selDetail, "sqlDataSource", data.data.ds);
											that.$set(that.columns[i], 'filters', []);
										}
									}
								});
							}
							else {
								that.$set(that.columns[i].selDetail, "sqlDataSource", []);
								that.$set(that.columns[i], 'filters', []);
							}
						}
					}
				},
				setLists() {
					FLD.formConfigAjax('SQLData/GetDataByPhysicalTableNameByPaging', {
						programId: localStorage.getItem("programId"),
						tableName: vm.params.physicalTableName,
						pageSize: vm.paging.pageSize,
						isForm: vm.params.isFormList,
						filterCondition: vm.filterStr,
						defaultOrder: vm.params.defaultOrder
					}, function (data) {
						vm.listFinished = false;
						vm.resultArray = data.ds;
						if (data.ds.length > 0) {
							//绑定总长度
							vm.paging.totalCount = data.ds1[0]["@TotalCount"];
						}
					})

				},
				listOnLoad() {
					vm.paging.pageIndex++;

					var queryColumns = [];
					for (var i = 0; i < vm.columns.length; i++) {
						queryColumns.push({
							queryKey: vm.columns[i].queryKey,
							colName: vm.columns[i].colName,
							queryWhere: vm.columns[i].colQueryWhere,
							filter_selection: vm.columns[i].filter_selection,
							querySort: vm.columns[i].querySort
						})
					}
					FLD.formConfigAjax('SQLData/GetDataByPhysicalTableNameByQueryPaging', {
						programId: localStorage.getItem("programId"),
						tableName: vm.params.physicalTableName,
						columns: queryColumns,
						currentCol: vm.currentCol,
						pageIndex: vm.paging.pageIndex,
						pageSize: vm.paging.pageSize,
						isForm: vm.params.isFormList,
						filterCondition: vm.filterStr,
						defaultOrder: vm.params.defaultOrder
					}, function (data) {
						vm.listLoading = false;
						vm.resultArray = vm.resultArray.concat(data.ds);

						if (data.ds.length > 0) {
							//绑定总长度
							vm.paging.totalCount = data.ds1[0]["@TotalCount"];
						} else {
							vm.listFinished = true;
						}
					})


				},
				showSelectTableDisplayValue(db, selectValue) {
					var dbList = db.sqlDataSource.filter(function (item) { return item[db.hiddenValue] == selectValue })
					if (dbList.length > 0) {
						return dbList[0][db.displayValue];
					}
					else {
						return "";
					}
				},
				//通过ajax获取显示值，增加性能查询
				showSelectTableDisplayValueByAjax(db, selectValue) {
					var that = this;
					if (db.chooseType == 1 || db.chooseType == 2) {
						try {
							var dbList = db.sqlDataSource.filter(function (item) { return item[db.hiddenValue] == selectValue })
							if (dbList.length > 0) {
								return dbList[0][db.displayValue];
							}
							else {
								return "";
							}
						} catch (e) {
							return "";
						}
					}
					else if (db.chooseType == 3) {
						try {
							var dbList = db.sqlDataSource.filter(function (item) { return ("," + selectValue + ",").indexOf("," + item[db.hiddenValue] + ",") >= 0 })
							if (dbList.length > 0) {
								var resultArray = [];
								for (var i = 0; i < dbList.length; i++) {
									resultArray.push(dbList[i][db.displayValue]);
								}
								return resultArray.join(',');
							}
							else {
								return "";
							}
						} catch (e) {
							return "";
						}
					}
					return "";
				},
				//打开简单下拉选
				openSimpleSelect(index, row) {
					var that = this;
					that.pickerIndex = index;

					that.simpleColumns = row.selDetail.sqlDataSource;
					that.showSimpleSelect = true;
				},
				//简单下拉选选中
				simpleSelectChange(value, index) {
					var that = this;
					var row = that.columns[that.pickerIndex];
					row.queryKey = that.simpleColumns[index][row.selDetail.hiddenValue];
					that.showSimpleSelect = false;
				},
				//打开复杂下拉选
				openComplexSelect(index, row) {
					var that = this;
					that.pickerIndex = index;
					var filter = '';
					api.openWin({
						name: '复杂筛选' + row.selDetail.url,
						url: 'formConfigScreen.html',
						reload: true,
						slidBackEnabled: false,
						pageParam: {
							filter: filter,
							screenName: row.selDetail.url,
							allowClear: true,
							type: row.selDetail.chooseType,
							isDetail: false,
							isHistory: true
						}
					})
				},
				openDatePicker(index) {
					vm.pickerIndex = index;
					vm.showDatePicker = true;
				},
				toggleFold(row) {
					if (typeof row.noFold === 'undefined') {
						this.$set(row, 'noFold', true);
					} else {
						row.noFold = !row.noFold;
					}
				},
				//清空所选日期
				clearDatePicker() {
					vm.columns[vm.pickerIndex].queryKey = '';
					vm.showDatePicker = false;
				},
				//确认当前所选日期
				confirmDatePicker(value) {
					vm.columns[vm.pickerIndex].queryKey = FLD.getFormatDate(value).split(' ')[0];
					vm.showDatePicker = false;
				},
				//查询数据
				searchList() {
					vm.filterStr = vm.filterDefault;
					if (vm.params.filterCondition) {
						vm.filterStr += ' and ' + vm.params.filterCondition;
					}

					vm.calSummaryData();
					//查询条件查询
					if (vm.columns.length > 0) {
						let operFilterArray = vm.columns.filter(function (item) {
							return item.queryKey && item.queryKey !== 0;
						});
						if (operFilterArray.length > 0) {
							vm.filterStr += " and ( ";
							var searchFilter = [];
							for (var i = 0; i < operFilterArray.length; i++) {
								if (operFilterArray[i].colType == 2) {
									searchFilter.push(" " + operFilterArray[i].colName + " " + 'in' + " ('" + operFilterArray[i].queryKey + "') ");
								} else {
									if (operFilterArray[i].colQueryWhere == 'like') {
										searchFilter.push(" " + operFilterArray[i].colName + " like '%" + operFilterArray[i].queryKey + "%' ");
									}
									else {
										searchFilter.push(" " + operFilterArray[i].colName + " " + operFilterArray[i].colQueryWhere + " '" + operFilterArray[i].queryKey + "' ");
									}
								}




							}
							vm.filterStr += " " + searchFilter.join(' and ') + " )";
						}
					}
					var queryColumns = [];
					for (var i = 0; i < vm.columns.length; i++) {
						queryColumns.push({
							queryKey: vm.columns[i].queryKey,
							colName: vm.columns[i].colName,
							queryWhere: vm.columns[i].colQueryWhere,
							filter_selection: vm.columns[i].filter_selection,
							querySort: vm.columns[i].querySort
						})
					}
					vm.showSearch = false;
					vm.paging.pageIndex = 1;


					// alert(JSON.stringify({
					// 	programId: localStorage.getItem("programId"),
					// 	tableName: vm.params.physicalTableName,
					// 	columns: queryColumns,
					// 	currentCol: vm.currentCol,
					// 	pageIndex: vm.paging.pageIndex,
					// 	pageSize: vm.paging.pageSize,
					// 	isForm: vm.params.isFormList,
					// 	filterCondition: vm.filterStr,
					// 	defaultOrder: vm.params.defaultOrder
					// }))
					FLD.formConfigAjax('SQLData/GetDataByPhysicalTableNameByQueryPaging', {
						programId: localStorage.getItem("programId"),
						tableName: vm.params.physicalTableName,
						columns: queryColumns,
						currentCol: vm.currentCol,
						pageIndex: vm.paging.pageIndex,
						pageSize: vm.paging.pageSize,
						isForm: vm.params.isFormList,
						filterCondition: vm.filterStr,
						defaultOrder: vm.params.defaultOrder
					}, function (data) {
						vm.listFinished = false;
						$('.h-t').scrollTop(0);
						vm.resultArray = data.ds;
						if (data.ds.length > 0) {
							//绑定总长度
							vm.paging.totalCount = data.ds1[0]["@TotalCount"];
						}
					})




				},
				sortSearch(col) {
					var that = this;
					if (col.isOrder) {
						that.currentCol = col.colName;
						for (var i in vm.columns) {
							if (vm.columns[i].isOrder && vm.columns[i].colName != col.colName) {
								vm.columns[i].querySort = vm.columns[i].defaultQuerySort
							}
						};
						if (col.querySort == 'asc') {
							col.querySort = 'desc';
						} else {
							col.querySort = 'asc';
						}

						that.searchList();
					}
				},
				intoPage(row) {
					var that = this;
					api.openWin({
						name: 'formConfig',
						url: 'formConfig.html',
						reload: true,
						slidBackEnabled: false,
						pageParam: {
							keyName: that.mainKey,
							keyValue: row[that.mainKey],
							objName: vm.params.detailName,
							titleName: that.titleName.replace(/历史/g, ''),
							parentObjName:that.objName.replace(/app_/g, '')
							// isPosted: that.filterDefault == 'Status >= 80' ? true : false
						}
					})

				},
				onClickLeft() {
					api.closeWin();
				}
			}
		})
	};
</script>

</html>